package view.fragme;

import javax.swing.JFrame;
import javax.swing.JPanel;

import view.BulletView;
import view.TankView;

public class MyJFrame extends JFrame {
    private static String EDITION = "2.8.x.8"; // 版本号
    public static final int GAME_WIDTH = 1000; // 屏幕的宽度
    public static final int GAME_HEIGHT = 800; // 屏幕的高度
    private JPanel jPanel;

    public MyJFrame() {
        jPanel = new JPanel();

        setTitle(EDITION);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLocation(300, 50);
        setSize(GAME_WIDTH, GAME_HEIGHT);
        setVisible(true);
        add(jPanel);
    }

    public void remove(TankView tankView) {
        jPanel.remove(tankView);
        jPanel.remove(tankView.getBloodView());
        jPanel.repaint();
    }

    public void remove(BulletView bulletView) {
        jPanel.remove(bulletView);
        jPanel.repaint();
    }

    public void add(TankView tankView) {
        jPanel.add(tankView);
        jPanel.add(tankView.getBloodView());
        setVisible(true);
    }

    public void add(BulletView bulletView) {
        jPanel.add(bulletView);
        setVisible(true);
    }

}
